import Request from '@/utils/request'
import type {
  CreateTalentPayloadType,
  QueryTalentsPayloadType,
  QueryTalentsResponseType,
  UpdateTalentPayloadType
} from '@/types/api/talent'

// 获取人才列表
export const getTalentListApi = (data: QueryTalentsPayloadType) => {
  return Request.Get<QueryTalentsResponseType>({
    url: '/talents',
    data
  })
}

// 创建人才
export const createTalentApi = (data: CreateTalentPayloadType) => {
  return Request.Post({
    url: '/talent',
    data
  })
}

// 更新人才
export const updateTalentApi = (data: UpdateTalentPayloadType) => {
  const { id, ...rest } = data
  return Request.Put({
    url: `/talent/${id}`,
    data: rest
  })
}

// 删除人才
export const deleteTalentApi = (data: { id: string }) => {
  const { id } = data
  return Request.Delete({
    url: `/talent/${id}`
  })
}
